package cn.edu.hunau.service.impl;


import cn.edu.hunau.dao.BannerDao;
import cn.edu.hunau.dao.IndexProductDao;
import cn.edu.hunau.dao.impl.BannerDaoImpl;
import cn.edu.hunau.dao.impl.IndexProductDaoImpl;
import cn.edu.hunau.pojo.Banner;
import cn.edu.hunau.pojo.IndexProduct;
import cn.edu.hunau.service.IndexService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author 苏佳
 * @Date 2022 11 03 16 26
 **/
public class IndexServiceImpl implements IndexService {
    private BannerDao bannerDao = new BannerDaoImpl();
    private IndexProductDao indexProductDao = new IndexProductDaoImpl();

    @Override
    public Map<String, Object> loadIndexData() {
        //1.加载主横幅数据
        List<Banner> mainBannerProducts = bannerDao.queryMainBannerOnline("0");
        //1.加载限时秒杀横幅数据
        List<Banner> killingBannerProducts = bannerDao.queryKillingBannerOnline("0");
        //2.加载捕头严选
        List<IndexProduct> selectedProducts = indexProductDao.queryByNews("0");
        //2.加载优选爆款
        List<IndexProduct> recommendProducts = indexProductDao.queryByNews("1");

        Map<String, Object> maps=new HashMap<>();
        maps.put("mainBanner",mainBannerProducts);
        maps.put("killingBanner",killingBannerProducts);
        maps.put("selected",selectedProducts);
        maps.put("recommend",recommendProducts);
        return maps;
    }
}
